package com.xjoyt.pay.master.po;

import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.OneToOne;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;

import com.fasterxml.jackson.annotation.JsonIgnore;

/**
 * 订单配置
 * 
 * @author Administrator
 *
 */
@Entity
@Table(name = "t_order_config")
public class OrderConfig {

	@Id
	@GeneratedValue(generator = "generator")
	@GenericGenerator(name = "generator", strategy = "assigned")
	@Column(name = "order_config_id", length = 36)
	public String id;

	/**
	 * 订单
	 */
	@OneToOne(targetEntity = Order.class, cascade = {})
	@JoinColumn(name = "order_id", foreignKey = @ForeignKey(name = "none"))
	@JsonIgnore
	public Order order;

	/**
	 * 通道商户号
	 */
	@Column(name = "no", length = 255)
	public String no;

	/**
	 * 通道密钥
	 */
	@Column(name = "sign_key", length = 255)
	public String key;
	
	/**
	 * 适配器下单地址
	 */
	@Column(name = "`url`", length = 255)
	public String url;

	/**
	 * 适配器代付地址
	 */
	@Column(name = "pay_url", length = 255)
	public String payUrl;

	/**
	 * 回调适配器地址
	 */
	@Column(name = "callback_url", length = 255)
	public String callbackUrl;

	/**
	 * 系统通知地址
	 */
	@Column(name = "notify_url", length = 255)
	public String notifyUrl;

	/**
	 * 适配器自动对账地址
	 */
	@Column(name = "check_url", length = 255)
	public String checkUrl;

	// /**
	// * 适配器退款地址
	// */
	// @Column(name = "back_url", length = 255)
	// public String backUrl;

	/**
	 * 通道
	 */
	@ManyToOne(targetEntity = Channel.class, cascade = {})
	@JoinColumn(name = "channel_id", foreignKey = @ForeignKey(name = "none"))
	@JsonIgnore
	public Channel channel;

	/**
	 * 通道名称
	 */
	@Column(name = "channel_name", length = 50)
	public String channelName;

	/**
	 * 通道编号
	 */
	@Column(name = "channel_no", length = 50)
	public String channelNo;

	/**
	 * 响应信息
	 */
	@Column(name = "result_message", length = 255)
	public String resultMessage;

	/**
	 * 响应码
	 */
	@Column(name = "result_code", length = 255)
	public String resultCode;

	/**
	 * 回调结果
	 */
	@Lob
	@Basic(fetch = FetchType.LAZY)
	@Column(name = "callback_result", columnDefinition = "TEXT")
	public String callbackResult;

	/**
	 * 回调响应
	 */
	@Lob
	@Basic(fetch = FetchType.LAZY)
	@Column(name = "callback_response", columnDefinition = "TEXT")
	public String callbackResponse;

	/**
	 * 代理商费率(‰)
	 */
	@Column(name = "cost_rate", precision = 10, scale = 6)
	public Double costRate;

	/**
	 * 前台通知地址
	 */
	@Column(name = "success_url", length = 255)
	public String successUrl;
}
